package com.tencent.sr.iris.basic.mp.restapi;

import com.tencent.sr.iris.basic.mp.dependency.NoticeDependency;
import com.tencent.sr.iris.basic.service.interfaces.request.NoticeListRequest;
import com.tencent.sr.iris.basic.service.interfaces.response.NoticeListResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@Slf4j
@Api("官方公告")
@RequestMapping("/iris/basic/mp/v1/notice")
public class NoticeController {

    @Resource
    private NoticeDependency noticeDependency;

    @ApiOperation("是否有新公告")
    @PostMapping("hasNew")
    HttpResult<Boolean> hasNew(@Valid @RequestBody NoticeListRequest request) {
        Boolean response = noticeDependency.hasNew(request);
        return HttpResult.succ(response);
    }

    @ApiOperation("查询公告列表")
    @PostMapping("list")
    HttpResult<List<NoticeListResponse>> list(@Valid @RequestBody NoticeListRequest request) {
        List<NoticeListResponse> response = noticeDependency.validNoticeList(request);
        return HttpResult.succ(response);
    }
}
